package cn.hfjava.kz.service.impl;

import cn.hfjava.kz.entity.dto.ApplicationQueryDTO;
import cn.hfjava.kz.entity.vo.*;
import cn.hfjava.kz.mapper.UserMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.hfjava.kz.entity.po.Application;
import cn.hfjava.kz.service.ApplicationService;
import cn.hfjava.kz.mapper.ApplicationMapper;
import com.github.pagehelper.PageHelper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 86177
 * @description 针对表【applications(个人申报审核表)】的数据库操作Service实现
 * @createDate 2024-07-16 23:17:39
 */
@Service
public class ApplicationServiceImpl extends ServiceImpl<ApplicationMapper, Application> implements ApplicationService {

    @Resource
    private ApplicationMapper applicationMapper;

    @Override
    public PageVO<ApplicationVO> findByPage(ApplicationQueryDTO applicationQueryDTO) {
        PageHelper.startPage(applicationQueryDTO.getCurPage(), applicationQueryDTO.getPageSize());
        List<ApplicationVO> applicationVoList = applicationMapper.getApplicationVoList(applicationQueryDTO);
        long total = applicationMapper.getApplicationVoCount(applicationQueryDTO);
        // 这里明确指定泛型类型参数为 UserVO
        PageVO pageVO = new PageVO<>(applicationQueryDTO.getCurPage(), applicationQueryDTO.getPageSize(), total, applicationVoList);
        return pageVO;
    }

    @Override
    public void saveApplication(Application application) {
        applicationMapper.insert(application);
    }
    @Override
    public WordVO getWordData(Integer studentId) {
        return applicationMapper.getWordData(studentId);
    }

    @Override
    public StudentAppliVO getByStudentId(Integer studentId) {
        return applicationMapper.getByStudentId(studentId);
    }
}




